#include <linux/init.h>
#include <linux/module.h>
#include <linux/interrupt.h>
#include <mach/platform.h>
#include <linux/platform_device.h>
#include <linux/input.h>
#include "btn_desc.h"



struct resource btn_res[] = {
    {
        .start  = IRQ_GPIO_A_START+28,
        .end    = IRQ_GPIO_B_START+28,
        .flags  = IORESOURCE_IRQ,
    },
    {
        .start  = IRQ_GPIO_B_START+30,
        .end    = IRQ_GPIO_B_START+30,
        .flags  = IORESOURCE_IRQ,
    },
};

btn_desc_t buttons_data[] = {
    {"up",PAD_GPIO_A+28, KEY_UP },
    {"down",PAD_GPIO_B+30, KEY_DOWN },
};

void btn_release(struct device *dev){
    printk("call %s \n",__func__);
}

static struct platform_device buttons_dev = {
    .name   =   "mybuttons",
    .dev    =   {
        .platform_data  =   buttons_data,
        .release = btn_release,
    },
    .resource = btn_res,
    .num_resources  = ARRAY_SIZE(btn_res),
};

int  __init btn_dev_init(void){
    platform_device_register(&buttons_dev);
    return 0;
}
void __exit btn_dev_exit(void){
    platform_device_unregister(&buttons_dev);
}
module_init(btn_dev_init);
module_exit(btn_dev_exit);
MODULE_LICENSE("GPL");
MODULE_AUTHOR("SGY");
